<template>
	<view class="toView">
		<view class="header">
			<image src="../../../static/img/quickly/summy/title@2x.png"></image>
			<view class="information">
				<view class="top">
					<view>会员：{{userInforDetail.realName || ''}}</view>
					<view>年龄：{{userInforDetail.age || ''}}岁</view>
					<view>性别：{{userInforDetail.sex == 1 ? '男' : userInforDetail.sex == 2 ? '女' : '未知'}}</view>
				</view>
				<view class="bottom">
					<view>签发人：{{healthName || ''}}</view>
					<view>签发日期：{{userInforDetail.updateTime | filterData2}}</view>
				</view>
			</view>
		</view>
		<view class="two"></view>
		<view class="three"></view>
		
		<view class="mainContent">
			<view class="informationBox">
				<view class="boxOne">
					<image mode="widthFix" src="../../../static/img/quickly/summy/title1@2x.png"></image>
					<view class="style">重要的体检阳性结果，重要的不良生活方式行为。</view>
				</view>
				<view class="boxTwo">
					<view v-if="catalog && catalog.length > 0" v-for="(item,index) in catalog" :key="index">{{[index+1]+'.'+item}}</view>
					<view v-if="catalog && catalog.length <= 0" style="text-align: center;">无问题目录</view>
				</view>
			</view>
			
			<view class="informationBox">
				<view class="boxOne">
					<image mode="widthFix" src="../../../static/img/quickly/summy/title2@2x.png"></image>
					<view class="style">主诉、症状、患者的主观感觉、疾病史、家族史和社会生活史等。</view>
				</view>
				<view class="boxTwo">
					<view v-if="subjective.length > 0" v-for="(item,index) in subjective" :key="index">{{[index+1]+'.'+item}}</view>
					<view v-if="subjective.length <= 0" style="text-align: center;">无主观描述</view>
				</view>
			</view>
			
			<!-- 其他信息 -->
			<view class="informationBox">
				<view class="boxOne"><!-- style="height: 120upx;" -->
					<image mode="widthFix" src="../../../static/img/quickly/summy/title3@2x.png"></image>
					<view class="style">包括体检所见、实验室检查结果、心理行为测量结果以及医生观察到的患者的态度、行为。</view>
				</view>
				<view class="boxTwo">
					<view v-if="subjective.length > 0" v-for="(item,index) in subjective" :key="index">{{[index+1]+'.'+item}}</view>
					<view v-if="subjective.length <= 0" style="text-align: center;">无客观资料</view>
				</view>
			</view>
			
			<view class="informationBox">
				<view class="boxOne" style="height: 120upx;">
					<image mode="widthFix" src="../../../static/img/quickly/summy/title4@2x.png" style="width: 569upx;"></image>
				</view>
				<view class="boxTwo">
					<view v-if="notRiskFactors.length > 0" v-for="(item,index) in notRiskFactors" :key="index">{{[index+1]+'.'+item}}</view>
					<view v-if="notRiskFactors.length <= 0" style="text-align: center;">无不可改变危险因素</view>
				</view>
			</view>
			
			<view class="informationBox">
				<view class="boxOne" style="height: 120upx;">
					<image mode="widthFix" src="../../../static/img/quickly/summy/title5@2x.png" style="width: 524upx;"></image>
				</view>
				<view class="boxTwo">
					<view style="margin-bottom: 10upx;" v-if="healthRiskFactors.length > 0" v-for="(item,index) in healthRiskFactors"  :key="index">
						{{[index+1]+'.'+item.key}}
						<view style="margin-left: .8em;font-weight: bold;"><rich-text :nodes="item.value"></rich-text></view>
					</view>
					<view v-if="healthRiskFactors.length <= 0" style="text-align: center;">无重点健康危险因素提示</view>
				</view>
			</view>
			
			<view class="informationBox">
				<view class="boxOne" style="height: 120upx;">
					<image mode="widthFix" src="../../../static/img/quickly/summy/title6@2x.png" style="width: 586upx;"></image>
				</view>
				<view class="boxTwo">
					<view v-if="riskFactorSpace.length > 0" v-for="(item,index) in riskFactorSpace" :key="index">{{[index+1]+'.'+item}}</view>
					<view v-if="riskFactorSpace.length <= 0" style="text-align: center;">无可改善危险因素空间</view>
				</view>
			</view>
			
			<view class="informationBox">
				<view class="boxOne" style="height: 120upx;">
					<image mode="widthFix" src="../../../static/img/quickly/summy/title7@2x.png" ></image>
				</view>
				<view class="boxTwo">
					<view v-if="otherIssues.length > 0" v-for="(item,index) in otherIssues" :key="index">{{[index+1]+'.'+item}}</view>
					<view v-if="otherIssues.length <= 0" style="text-align: center;">无其他问题</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import {getUrlParam,filterData,age} from '@/static/js/filter.js';
	export default {
		data() {
			return {
				catalog: {},
				subjective: {},
				objective: {},
				notRiskFactors: {},
				healthRiskFactors: {},
				riskFactorSpace: {},
				otherIssues:  {},
				userInforDetail: {},
				healthName: '',
			}
		},
		methods: {
			age
		},
		mounted(){
			const _this = this;
			_this.id = getUrlParam('id');
			_this.userId = getUrlParam('userId');
			if(_this.userId) {
				this.$api.findByUserId(_this.userId).then((res) => {
					this.userInforDetail = res.data && res.data.result;
					this.userInforDetail.age = age('',this.userInforDetail.birthday);
				})
			}
			if(_this.id) {
				_this.$api.userRisksId(_this.id,3,_this.userId).then((res) => {
					if(res.data.returnCode == '200') {
						_this.userId = res.data.result && res.data.result.appHealthRisks.userId;
						_this.userName = res.data.result && res.data.result.appHealthRisks.userName;
						_this.healthName = res.data.result && res.data.result.appHealthRisks.healthName;
						_this.catalog =  res.data.result.appHealthRisks.catalog && JSON.parse(res.data.result.appHealthRisks.catalog).map((b) => {
							return b.value
						})
						_this.subjective = res.data.result.appHealthRisks.subjective && JSON.parse(res.data.result.appHealthRisks.subjective).map((b) => {
							return b.value
						})
						_this.objective = res.data.result.appHealthRisks.objective && JSON.parse(res.data.result.appHealthRisks.objective).map((b) => {
							return b.value
						})
						_this.notRiskFactors = res.data.result.appHealthRisks.notRiskFactors && JSON.parse(res.data.result.appHealthRisks.notRiskFactors).map((b) => {
							return b.value
						})
						_this.healthRiskFactors = res.data.result.appHealthRisks.healthRiskFactors && JSON.parse(res.data.result.appHealthRisks.healthRiskFactors).map((b) => {
							const value = b.parameterValue.value.substr(0,3) + '建议:' + b.parameterValue.value.substr(3)
							return {
								key : b.parameterValue.name,
								value : value,
							}
						})
						_this.riskFactorSpace = res.data.result.appHealthRisks.riskFactorSpace && JSON.parse(res.data.result.appHealthRisks.riskFactorSpace).map((b) => {
							return b.value
						})
						_this.otherIssues = res.data.result.appHealthRisks.otherIssues && JSON.parse(res.data.result.appHealthRisks.otherIssues).map((b) => {
							return b.value
						})
					}
				})
			}
		},
	}
</script>

<style lang="scss" scoped>
	@import "@/static/css/quickly/Intervention/toView.scss" ;
</style>
